using UnityEngine;
using System.Collections;

public class PlayerAnims : MonoBehaviour
{
	
	OTAnimatingSprite mySprite;
	Vars.anim currentAnim;

	
	// Use this for initialization
	void Start ()
	{
		mySprite = GetComponent<OTAnimatingSprite>();
	}
	
	// Update is called once per frame
	void Update ()
	{
	
		// run left
		if(Vars.isLeft && !Vars.falling && currentAnim != Vars.anim.WalkLeft)
		{
			currentAnim = Vars.anim.WalkLeft;
			mySprite.Play("player_walk_left");
		}
		if(!Vars.isLeft && !Vars.falling && currentAnim != Vars.anim.StandLeft && Vars.facingDir == 1)
		{
			currentAnim = Vars.anim.StandLeft;
			mySprite.Play("player_stop_left"); // stand left
		}		
		// run right
		if(Vars.isRight && !Vars.falling && currentAnim != Vars.anim.WalkRight)
		{
			currentAnim = Vars.anim.WalkRight;
			mySprite.Play("player_walk_right");
		}
		if(!Vars.isRight && !Vars.falling && currentAnim != Vars.anim.StandRight && Vars.facingDir == 2)
		{
			currentAnim = Vars.anim.StandRight;
			mySprite.Play("player_stop");
			//mySprite.ShowFrame(0); // stand left
			
		}		
		
	}
}

